package org.dubnation.base.excel.download.controller;

import org.dubnation.base.excel.download.service.IDownloadService;
import org.dubnation.base.excel.download.util.DownloadNeed;
import org.dubnation.base.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RequestMapping("/download")
@RestController
public class DownloadController {

    @Autowired
    private IDownloadService downloadService;

    /**
     * 导出文件
     * @param downloadNeed
     * @return
     */
    @PostMapping("/department")
    public AjaxResult download(@RequestBody DownloadNeed downloadNeed, HttpServletResponse response) {
        downloadService.download(downloadNeed, response);
        return AjaxResult.me();
    }
}
